﻿using Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IService
{
    /// <summary>
    /// 数据字典服务接口
    /// 封装字典的缓存管理和业务逻辑
    /// </summary>
    public interface ISysDictService
    {
        /// <summary>
        /// 根据字典类型编码获取字典数据列表
        /// 优先从Redis缓存中获取，如果缓存中不存在，则从数据库中获取，并将数据缓存到Redis中
        /// </summary>
        /// <param name="dicTypeCode">字典类型编码（如“Sex”）</param>
        /// <returns>字典数据列表</returns>
        Task<List<SysDictData>> GetDictDatasByCodeAsync(string dicTypeCode);

        /// <summary>
        /// 根据字典类型编码和字典值获取对应的字典标签
        /// 例如：根据Sex和‘1’获取‘男’
        /// </summary>
        /// <param name="dictTypeCode">字典编码类型</param>
        /// <param name="dictValue">字典值</param>
        /// <returns>字典标签（如未找到返回空）</returns>
        Task<String> GetDictLabelAsync(string dictTypeCode, string dictValue);

        /// <summary>
        /// 刷新所有字典的Redis缓存
        /// </summary>
        /// <returns></returns>
        Task RefreshAllDictCacheAsync();

        /// <summary>
        /// 刷新指定字典类型的Redis缓存
        /// </summary>
        /// <param name="dictTypeCode">字典类型编码</param>
        /// <returns></returns>
        Task RefreshDictCacheByCodeAsync(string dictTypeCode);
    }
}
